package test1231;

public class CompanyA {

    String name;
    Father[] arr = new Father[4];
    int i = 0;

    public CompanyA() {
    }

    public CompanyA(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "CompanyA{" +
                "name='" + name + '\'' +
                '}';
    }


    // 面向父类做开发！！
    public void add(Father father) {
        arr[i] = father;
        i++;
    }

    public double getAllSalary() {
        double sum = 0;
        for (Father f:arr) {
            sum += f.m(); // 多态！！！！
            // 难点：多种类型的员工计算工资的方法不同！
        }
        return sum;
    }

}